rest_query_var-{$key}
Filter HookDescription
Determines the allowed query_vars for a get_items() response and prepares them for WP_Query.Hook Information
File Location |
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
View on GitHub
|
Hook Type | Filter |
Line Number | 551 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$prepared_args
|
Optional. Prepared WP_Query arguments. Default empty array. |
WP_REST_Request
|
$request
|
Optional. Full details about the request. |
Usage Examples
Basic Usage
<?php
// Hook into rest_query_var-{$key}
add_filter('rest_query_var-{$key}', 'my_custom_filter', 10, 2);
function my_custom_filter($prepared_args, $request) {
// Your custom filtering logic here
return $prepared_args;
}
Source Code Context
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php:551
- How this hook is used in WordPress core
<?php
546 protected function prepare_items_query( $prepared_args = array(), $request = null ) {
547 $query_args = array();
548
549 foreach ( $prepared_args as $key => $value ) {
550 /** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php */
551 $query_args[ $key ] = apply_filters( "rest_query_var-{$key}", $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
552 }
553
554 // Map to proper WP_Query orderby param.
555 if ( isset( $query_args['orderby'] ) && isset( $request['orderby'] ) ) {
556 $orderby_mappings = array(
PHP Documentation
<?php
/**
* Determines the allowed query_vars for a get_items() response and prepares
* them for WP_Query.
*
* @since 5.0.0
*
* @param array $prepared_args Optional. Prepared WP_Query arguments. Default empty array.
* @param WP_REST_Request $request Optional. Full details about the request.
* @return array Items query arguments.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
Related Hooks
Related hooks will be displayed here in future updates.